package com.ruoyi.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.work.mapper.WorkClientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkMediaWxMapper;
import com.ruoyi.work.domain.WorkMediaWx;
import com.ruoyi.work.service.IWorkMediaWxService;
import com.ruoyi.common.core.text.Convert;

/**
 * 微信媒体资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-02
 */
@Service
public class WorkMediaWxServiceImpl implements IWorkMediaWxService 
{
    @Autowired
    private WorkMediaWxMapper workMediaWxMapper;
    @Autowired
    private WorkClientMapper workClientMapper;

    /**
     * 查询微信媒体资料
     * 
     * @param mediaId 微信媒体资料主键
     * @return 微信媒体资料
     */
    @Override
    public WorkMediaWx selectWorkMediaWxByMediaId(Long mediaId)
    {
        return workMediaWxMapper.selectWorkMediaWxByMediaId(mediaId);
    }

    /**
     * 查询微信媒体资料列表
     * 
     * @param workMediaWx 微信媒体资料
     * @return 微信媒体资料
     */
    @Override
    public List<WorkMediaWx> selectWorkMediaWxList(WorkMediaWx workMediaWx)
    {
        return workMediaWxMapper.selectWorkMediaWxList(workMediaWx);
    }

    /**
     * 新增微信媒体资料
     * 
     * @param workMediaWx 微信媒体资料
     * @return 结果
     */
    @Override
    public int insertWorkMediaWx(WorkMediaWx workMediaWx)
    {
        workMediaWx.setCreateTime(DateUtils.getNowDate());
        workMediaWx.setContacts(workClientMapper.selectWorkClientByClientId(workMediaWx.getContactId()).getClientName());
        return workMediaWxMapper.insertWorkMediaWx(workMediaWx);
    }

    /**
     * 修改微信媒体资料
     * 
     * @param workMediaWx 微信媒体资料
     * @return 结果
     */
    @Override
    public int updateWorkMediaWx(WorkMediaWx workMediaWx)
    {
        workMediaWx.setUpdateTime(DateUtils.getNowDate());
        return workMediaWxMapper.updateWorkMediaWx(workMediaWx);
    }

    /**
     * 批量删除微信媒体资料
     * 
     * @param mediaIds 需要删除的微信媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaWxByMediaIds(String mediaIds)
    {
        return workMediaWxMapper.deleteWorkMediaWxByMediaIds(Convert.toStrArray(mediaIds));
    }

    /**
     * 删除微信媒体资料信息
     * 
     * @param mediaId 微信媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaWxByMediaId(Long mediaId)
    {
        return workMediaWxMapper.deleteWorkMediaWxByMediaId(mediaId);
    }
}
